//
//  AuthenticationApi.h
//  NZIdAuthent
//
//  Created by Liulu on 2017/6/20.
//  Copyright © 2017年 zhilinXu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "NZOcrModel.h"

typedef enum : NSInteger {
    NZAuthSuccess          =  0,          /**< 认证通过 */
    NZErrAuthFail          = -1,          /**< 认证不通过，包括身份信息不匹配、人像不匹配等 */
    NZErrParameter         = -2,          /**< 参数错误，包括合作方参数错误、用户身份信息参数错误 */
    NZErrConnectionError   = -3,          /**< 网络错误  */
    NZErrOliveFail         = -4,          /**< 活体检测失败，包括用户取消活体检测和活体检测不通过 */
    NZErrPlatformAuth      = -5,          /**< 平台鉴权失败，包括合作方鉴权失败，签名错误等 */
    NZErrSystem            = -6,          /**< 系统异常 */
    NZErrUnkonw            = -100         /**< 未知错误 */
} NZErrorOption;

@interface NZAuthError :NSObject

@property (nonatomic, assign) NZErrorOption code;

@property (nonatomic, copy) NSString *errDescription;

@end

@interface NZUserModel : NSObject

@property (nonatomic, strong) NSString *name;//身份证姓名,eg:张三

@property (nonatomic, strong) NSString *idCardNumber;//身份证号码,18位

@property (nonatomic, strong) NSString *picture;//用户头像,base64字符串,JPEG格式,大小10KB-50KB识别率最高
@property (nonatomic, strong) NSString *mobile;//手机号,11位

@property (nonatomic, strong) NSString *bankCardNumber;//银行卡号

@property (nonatomic, strong) NSString *transactionid; //流水号 32位以内随机数

@property (nonatomic, strong) NSString *IsEncryptedPic;//图片是否加密  1 加密 0 不加 默认0

@property (nonatomic, strong) NSString *IsReturnRawPic;//是否返回解密图像  1 返回 0 不返回  只有IsEncryptedPic 是1的时候 才有意义

//图片base64字符串
@property (nonatomic, strong) NSString *image_url1;
@property (nonatomic, strong) NSString *image_url2;
@end

@interface NZPartnerModel : NSObject

@property (nonatomic,copy) NSString *appID;// APPID

@property (nonatomic,copy) NSString *partnerID;//合作方ID

@property (nonatomic,copy) NSString *appSecret;//秘钥

@property (nonatomic,copy) NSString *privateKey;//私钥

@end

typedef void(^AuthCompletion)(BOOL result, NZAuthError *error); //认证结果block

/**
 result= @{
 @"result":@"0",  //0 成功  1失败
 @"img":@“xxxx”   //活体认证要求返回图片 --- 解密图片
 }
 */
typedef void(^IDAuthCompletion)(NSDictionary *result, NZAuthError *error); //身份认证认证结果block
/**
 similarity :图片相似度
 */
typedef void(^PictureComparisonCompletion)(NSString *similarity, NZAuthError *error); //图片对比block

@interface AuthenticationApi : NSObject

//如果需要用测试环境调试，传参数YES
+ (void)setDebug:(BOOL)isDebug;

//二项
+ (void)authenticateModeTwoWithUserModel:(NZUserModel *)userModel
                            PartnerModel:(NZPartnerModel *)partnerModel
                              Completion:(IDAuthCompletion)authCompletion;

//二项+人像
+ (void)authenticateModeTwoPortraitWithUserModel:(NZUserModel *)userModel
                                    PartnerModel:(NZPartnerModel *)partnerModel
                                      Completion:(IDAuthCompletion)authCompletion;
//二项+活体人像
+ (void)authenticateModeOliveTwoPortraitWithUserModel:(NZUserModel *)userModel
                                         PartnerModel:(NZPartnerModel *)partnerModel
                                           Completion:(IDAuthCompletion)authCompletion;

// 二项+人像+手机号
+ (void)authenticateModeTwoPortraitAndMobileWithUserModel:(NZUserModel *)userModel
                                    PartnerModel:(NZPartnerModel *)partnerModel
                                      Completion:(IDAuthCompletion)authCompletion;

//二项+活体检测人像+手机号
+ (void)authenticateModeOliveTwoPortraitAndMobileWithUserModel:(NZUserModel *)userModel
                                         PartnerModel:(NZPartnerModel *)partnerModel
                                           Completion:(IDAuthCompletion)authCompletion;

//银行卡三要素
+ (void)authenticateModeBankCardThreeWithUserModel:(NZUserModel *)userModel
                                      PartnerModel:(NZPartnerModel *)partnerModel
                                        Completion:(AuthCompletion)authCompletion;
//银行卡四要素
+ (void)authenticateModeBankCardFourWithUserModel:(NZUserModel *)userModel
                                     PartnerModel:(NZPartnerModel *)partnerModel
                                       Completion:(AuthCompletion)authCompletion;

//OCR
+ (void)ocrWithUserModel:(NZOcrModel *)ocrModel
            PartnerModel:(NZPartnerModel *)partnerModel
                CallBack:(void(^)(NSDictionary *dic,NZAuthError *error))block;
//图片比对
+ (void)PictureComparisonWithUserModel:(NZUserModel *)userModel
                          PartnerModel:(NZPartnerModel *)partnerModel
                            Completion:(PictureComparisonCompletion)authCompletion;
@end
